<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Order.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>/css/biaoge.css" />
		<link rel="stylesheet" type="text/css"
			href="fancybox/jquery.fancybox-1.3.4.css" />
		<script type="text/javascript" src="jquery/js/jquery-1.8.2.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.easing-1.3.pack.js"></script>
		<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<script type="text/javascript" src="<%=basePath%>/My97DatePicker/WdatePicker.js"></script>

	</head>
	<script type="text/javascript">
  
   function fangda(tupian){
   $("#"+tupian+"k").fancybox();
  }
  
   function getone(a){
     window.location="orderdetail.action?orderid="+a;
   }
   
 
  
   function sele(){
  var da=$("#riqi").val();
   var indusname=$("#gongchang").val();
   var orderId=$("#orderid").val();
   
   //alert("selectBydate.action?datetime='"+da+"'&&indusid="+indusid);
   window.location="selectBydate.action?datetime="+da+"&&indusname="+indusname+"&&page=1&&orderId="+orderId;
  }
   $(document).ready(function(){
   setInterval(
      ajaxfanstate
,5000);
   }
   );
   
  function ajaxfanstate(){
   var tm=$("#datetime").val();
   var indus=$("#indusname").val();
    $.post("selectorderbydate.action",
				{datetime:tm,indusname:indus},  
      		function(data){
      		//alert("asdfasdfasd");
      		 var len=data.jsonob.length;
      		 //$("#"+id+"").html("已发货");
      		 //var k='<font color="blue">已发货</font>';
      		 for(var i=0;i<len;i++)
      		 {
      		 if(data.jsonob[i].costFeedback!=null&&data.jsonob[i].costFeedback!=""){
      		 //alert("asda");
      		 document.getElementById(data.jsonob[i].orderId).innerHTML="工厂有反馈";
      		 }
      		 }
      		},
      		 "json"
      		);  
      		//alert("aaaaa");
  }
  function kai(a){
   var k=document.getElementById("zuihou");
  if(a<=1) k.innerHTML="这已经第一页了";
  }
  function zui(a,b){
  var z=document.getElementById("zuihou");
  if(a>=b) z.innerHTML="这已经是最后一页了";
  }
  $().ready(function() {
	var options = "<option value=''>-----请  选  择-----</option>";
       $.post(
       "getAllIndustry",
       function(data){
         $.each(data.gonglist,function(index,value){
        options = options+"<option value="+value.industryName+">"+value.industryName+"</option>";
        
         });
         $("select").html(options);
       },"json"
       );
       $("select").click(function(){
       $("#gongchang").val($("select").val());
       });
	});
  </script>
	<body>
		<!--   <div style="margin-left:100px">   
<div style="float:right;margin-top:-70px">订单查询：<br>选择时间：<input type="text" name="riqi" id="riqi" onclick="JTC.setday({format:'yyyy-MM-dd', readOnly: true})"><br>
      工厂名称：<input type="text" name="gongchang" id="gongchang"><input type="button"  value="查询" onclick="sele()">
        </div>  -->


		<div align="center">
			<table>
				<tr>
					<td colspan="2" align="center">
						订单查询：
					</td>
				</tr>
				<tr>
					<td>
						选择时间：
					</td>
					<td>
						<input type="text" name="riqi" id="riqi" value="${datetime }"
							class="Wdate" onfocus="WdatePicker()">
					</td>
				</tr>
				<tr>
					<td>
						工厂名称：
					</td>
					<td>
						<input type="text" name="gongchang" id="gongchang" value="${indusname}">
						<select></select>
					</td>
				</tr>
				<tr>
					<td>
						订单编号
					</td>
					<td>
						<input type="text" name="orderid" id="orderid">
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<input type="button" value="查询" onclick="sele()">
					</td>
				</tr>
			</table>
		</div>




		<div align="center" id="order">
			<!-- <div style="width:1000px;margin-left: 150px;margin-top:70px" id="order"> -->
			<font size="3" color="red">${datetime}${indusname}的订单如下：如果没有制作CDR文件，可以点击订单详细信息查看图片制作然后上传图片即可。</font>
			<table id="mytable" cellspacing="0" width="950">
				<tr>
					<td>
						订单编号
					</td>
					<td>
						订单图片
					</td>
					<td>
						订单名字
					</td>
					<td>
						下单用户
					</td>
					<td>
						下单时间
					</td>
					<td>
						订单详细信息
					</td>
					<td>
						订单对应工厂
					</td>
					<td>
						快递单号
					</td>
					<td>
						订单状态
					</td>
					<td>
						是否制作CDR文件
					</td>
				</tr>
				<c:forEach items="${orderlist}" var="order">
					<c:if test="${!empty order.orderName}">
						<tr>
							<td>
								${order.orderId}
							</td>
							<td>
								<img src="${order.orderPic}" style="height: 76px; width: 100px" />
								<a id="${order.orderId}k" href="${order.orderPic}"><img
										src="img/fangda.gif" onclick="fangda('${order.orderId}')"
										style="float: right;">
								</a>
							</td>
							<td>
								${order.orderName}
							</td>
							<td>
								${order.userName}
							</td>
							<td>
								<fmt:formatDate value="${order.orderTime}"
									pattern="yyyy-MM-dd HH:mm:ss" />
							</td>
							<td>
								<input type="button" value="查看详细信息"
									onclick="getone('${order.orderId}')">
							</td>
							<td>
								${order.industryName}
							</td>
							<td>
								${order.orderFreight}
							</td>
							<c:choose>
								<c:when test="${order.orderState==0}">
									<td id="${order.orderId}" >
										<font size="3" color="black">用户未付款</font>
									</td>
								</c:when>

								<c:when test="${order.orderState==1}">
									<td id="${order.orderId}">
										<font size="3" color="red">用户已付款，未发货</font>
										<c:if test="${! empty order.costFeedback}">
											<font size="3" color="red">工厂有反馈</font>
										</c:if>
									</td>
								</c:when>

								<c:when test="${order.orderState==2}">
									<td id="${order.orderId}">
										<font size="3" color="blue">已发货</font>
										<c:if test="${! empty order.costFeedback}">
											<font size="3" color="blue">工厂有反馈</font>
										</c:if>
									</td>
								</c:when>

								<c:when test="${order.orderState==3}">
									<td id="${order.orderId}">
										<font size="3" color="grey">成功交易</font>
									</td>
								</c:when>

							</c:choose>

							<c:if test="${empty order.CDRurl}">
								<td>
									<font size="3" color="red">未制作</font>
								</td>
							</c:if>
							<c:if test="${!empty order.CDRurl}">
								<td>
									已制作
								</td>
							</c:if>
							<tr>
					</c:if>
				</c:forEach>

			</table>
			
			<div style="margin-left: 350px; margin-top: 50px">
				<a href="selectBydate.action?datetime=${datetime }&&indusname=${indusname }&&page=1"> 首页</a>&lt;
				<a href="selectBydate.action?datetime=${datetime }&&indusname=${indusname }&&page=${pagenow-1}"
					onclick="kai(${pagenow})">上一页</a>
				<strong>第${pagenow}页/共${pagecount}页</strong>
				<a href="selectBydate.action?datetime=${datetime }&&indusname=${indusname }&&page=${pagenow+1}"
					onclick="zui(${pagenow},${pagecount})"> 下一页</a>&gt;
				<a href="selectBydate.action?datetime=${datetime }&&indusname=${indusname }&&page=${pagecount}">末页</a>&gt;&gt;
				</p>
				<font size="2" color="red" id="zuihou"></font>
			</div>
			<img
				src="<%=request.getContextPath()%>/img/resources/webbeiUserInfo/xiaoming/userCustom/全罩车衣630480.png"
				style="width: 100px">
			<br>
		
		</div>
		</div>

	</body>
</html>
